package com.lagou.product_springcloud.controller;

import com.lagou.product_springcloud.pojo.Products;
import com.lagou.product_springcloud.producer.ProductsProducer;
import com.lagou.product_springcloud.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("products")
public class ProductsController {
    @Autowired
    private ProductsService productsService;

    @PostMapping("insert")
    public String insert(@RequestBody Products products){
        Integer id = productsService.insertProduct(products);
        String msg = ProductsProducer.sendMsg(id);
        return msg;
    }
}
